/**
 * @author of2198
 * @date 2017/3/10.
 * @description
 */

var config = require('../config/config');
var fse = require('fs-extra');
let path = require('path');

module.exports = commonUtil = {};
/**
 * 自动生成用户维度上传列表文件 ;;
 */
commonUtil.generateUserDimension = function (userReords = {}) {

    let result = [];

    for (let uid in userReords) {
        result.push(`${uid},${userReords[uid].level}类用户,${userReords[uid].industry || '其它'}行业,${userReords[uid].manageType || '其它'}经营方式,${userReords[uid].signStatus || '未签约'}`);
    }

    config.gaConfig.webPropertys.forEach(webPropertyItem => {
        fse.outputFile(path.join(__dirname, '../output/all-' + webPropertyItem.name + '.csv'),
            ["ga:userId," + webPropertyItem.demensionMap.userLv + ","+ webPropertyItem.demensionMap.industry + ","
            + webPropertyItem.demensionMap.manageType + "," + webPropertyItem.demensionMap.signStatus].concat(result).join('\r\n'),
            function (err) {

            })
    });
}